<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue使用之传值校验</title>
    <script src="../vue.js" type="text/javascript"></script>
</head>
<body>
<div id="app">
    <boy-component :msg="msg"></boy-component>
</div>

<script type="text/javascript">
    var boyComponent = {
        props: {
            msg: {
                // type:Array
                type: String,
                required: true,
                default: 'hello',
                validator: function (value) {
                    // return value.length < 5
                    return value.length
                }
            }
        },
        data(){
            return {
                info: ''
            }
        },
        created(){
            // this.msg=this.msg+'test'
            this.info=this.msg
            console.log(this.msg+'test')
        },
        template: `<div>{{msg}}</div>`
    }

    var app = new Vue({
        el: '#app',
        data: {
            msg: 'hello，子组件'
        },
        components: {
            boyComponent
        }
    })
</script>
</body>
</html>